package com.xja.config;

import com.xja.utils.ChatClientHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author 蔡建国
 * Date  2025/4/20 19:23
 * 注册一些Spring AI 的 Client
 */
@Component
@Slf4j
public class ModelConfig {

    @Autowired
    private ChatClientHolder chatClientHolder;

    // 每五分钟刷新
    @Scheduled(fixedRate = 60 * 5 * 1000)
    public void refresh() {
        log.info("refresh all chat client");
        chatClientHolder.refreshAllChatClient();
    }
}